﻿
@using AntUnion.FrameWork.Util;
@model AntUnion.FrameWork.Model.Models.CrmUser
@{
    ViewData["Title"] = "CRMAccountInfo";
    Layout = "~/Areas/Console/Views/Shared/_Layout.cshtml";
}
@section head{
    <script type="text/javascript">
        var renderTable;
        var setSelectData;
        var userType = 0;

        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            treetable: 'treetable-lay/treetable',
            index: 'lib/index'
        }).use(['table', 'treetable', 'index', 'laydate', 'form', 'element'], function () {
            var $ = layui.$
                , form = layui.form
                , admin = layui.admin
                , table = layui.table
                , element = layui.element
                , laydate = layui.laydate
                , parentFrameIndex = parent.layer.getFrameIndex(window.name);

            /**多语言初始化 */
            top.SetFormPageLanguage(layui);
            $.getJSON("/Console/Roles/GetListJson?userType=1", function (result) {
                let plat = result.data;
                for (var key in top.lang) {
                    if (top.lang.hasOwnProperty(key)) {
                        if (key === "none") {
                            var text = top.lang[key];
                            $('#roles').append(new Option(text, ""));
                        }
                    }
                }
                plat.forEach(function (v) {
                    for (var key in top.lang) {
                        if (top.lang.hasOwnProperty(key)) {
                            if (key === v.remark) {
                                var text = top.lang[key];
                                $('#roles').append(new Option(text, v.id));
                            }
                        }
                    }
                });
                layui.form.render("select");
            });
            form.on('submit(identityInfoConfirmBtn)', function (data) {
                /**提示语弹框 */
                var State = $('input[name ="State"]:checked').val();
                if (typeof (State) == "undefined") {
                    top.AlertByKey(layui, "pleaseSelectStatus", 0);
                    return false;
                }
                if (State == 2) {
                if ($('#programme').val() === "") {
                    top.AlertByKey(layui, "pleaseSelectProgramme", 0);
                    return false;
                    }
                }
                layui.layer.confirm(top.lang.confirmExecute, {
                    title: top.lang.certificationAudit,
                    btn: [top.lang.confirmBtn, top.lang.closeBtn]
                }, function (index, layero) {
                    $.ajax({
                        type: "POST",
                        url: "/Console/ProxyAudit/Edit",
                        data: {
                            "Id": $('#Id').val(),
                            "State": State,
                            "Remarks": $('#remarks').val(),
                            "Reviewer": $('#reviewer').val(),
                            "programme": $('#programme').val()
                        },
                        async: true,
                        error: function (request) {
                            alert("Connection error");
                        },
                        beforeSend: function (xhr) {
                            layui.layer.load();
                        },
                        success: function (data) {
                            var item = eval(data);
                            if (item.code == 0) {
                                /**提示语弹框 */
                                top.ShowMessageByKey(layui, "submitSuccess", 6, 1000, function () {
                                    parent.layui.index.openTabsPage("/Console/AuthenticationVerify/Index");
                                    parent.layui.admin.events.refresh();
                                    top.delectTable("layadmin-layout-tabs", "/Console/AuthenticationVerify/UserViewDetail?id=" + $("#Id").val());
                                });

                            } else {
                                /**提示语弹框 */
                                top.AlertByKey(layui, item.msg, 0);
                            }
                            layer.closeAll('loading');
                        }
                    });
                });
                return false;
            });

            form.on('submit(identityInfoCancel)', function (data) {
                parent.layui.admin.events.closeThisTabs();

            });

             $.getJSON("/Console/RebateScheme/GetListJson?page=0&limit=0", function (result) {
                let plat = result.data;
                $('#programme').append(new Option(top.lang.pleaseSelect, ""));
                plat.forEach(function (v) {
                    $('#programme').append(new Option(v.names, v.id));
                });
                if ("@Model.SchemeId" != "0") {
                    $('#programme').val("@Model.SchemeId");
                }
                layui.form.render("select");
            });


            //图片预览事件
            $('.uploadShowView img').click(function (e) {
                previewImg(this);
                e.stopPropagation()
            });

        });
        function imgcli(obj) {
            var src = $(obj).attr("src");
            var imgHtml = "<div style='overflow:auto;display:flex;align-items:center;width:700px;height:700px;justify-content:center;'>"
                + "<img style='width:auto;height:auto;text-align:center;' src='" + src + "' /></div>";
            //弹出层
            layer.open({
                type: 1,
                shade: true,
                shade: [0.4, '#000000'],
                title: false, //不显示标题
                area: ['auto', 'auto'],
                content: imgHtml, //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
                cancel: function () {

                }
            });
        }

    </script>
}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend lay-event='agentInformation'>代理信息</legend>
                    </fieldset>
                    <div class="layui-form">
                        <div class="layui-row layui-col-space10 layui-form-item">
                            <div class="layui-col-lg6">
                                <label class="layui-form-label" lay-event='fullName'>姓名：</label>
                                <div class="layui-input-block">
                                    <label class="layui-form-label">@Model.Name</label>
                                </div>
                            </div>
                            <div class="layui-col-lg6">
                                <label class="layui-form-label" lay-event='CRMAccount'>账户ID：</label>
                                <div class="layui-input-block">
                                    <label class="layui-form-label">@Model.LoginName</label>
                                </div>
                            </div>

                            @if (ViewBag.personalInformations != null)
                            {
                                List<AntUnion.FrameWork.Model.Models.CrmKyc> personalInformations = ViewBag.personalInformations as List<AntUnion.FrameWork.Model.Models.CrmKyc>;
                                if (personalInformations != null && personalInformations.Count > 0)
                                {
                                    foreach (AntUnion.FrameWork.Model.Models.CrmKyc crmKyc in personalInformations)
                                    {
                                        if (crmKyc.Type == "image")
                                        {
                                            <div class="layui-col-lg6">
                                                <label class="layui-form-label" lay-event="@crmKyc.ControlId">@crmKyc.Name</label>
                                                @if (crmKyc.Required == 0)
                                                {
                                                    <span class="required">*</span>
                                                }
                                                <div class="layui-upload-drag uploadView" id="@crmKyc.ControlId">
                                                    <div class="uploadShowView" id="@(crmKyc.ControlId+"View")">
                                                        <img src="@crmKyc.Value" class="personInput" style="max-width: 100px;max-height: 100px;" id="@(crmKyc.ControlId+"Img")">
                                                    </div>
                                                </div>
                                            </div>
                                        }
                                    }
                                }
                            }
                            @if (ViewBag.promotions != null)
                            {
                                AntUnion.FrameWork.Model.Models.Promotion promotion = ViewBag.promotions as AntUnion.FrameWork.Model.Models.Promotion;
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="applicationContent">申请内容</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid layui-word-aux" id="Cont" name="Cont">@promotion.Cont</div>
                                    </div>
                                </div>
                            }
                        </div>
                    </div>


                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend lay-event='auditRecords'>审核记录</legend>
                    </fieldset>
                    <div class="layui-form">
                        <div class="layui-row layui-col-space10 layui-form-item">
                            <ul class="layui-timeline">
                                @if (ViewBag.crmAuditLogsList != null)
                                {
                                    List<AntUnion.FrameWork.Model.Models.CrmAuditLog> crmAuditLogs = ViewBag.crmAuditLogsList as List<AntUnion.FrameWork.Model.Models.CrmAuditLog>;
                                    foreach (AntUnion.FrameWork.Model.Models.CrmAuditLog crmAuditLog in crmAuditLogs)
                                    {
                                        <li class="layui-timeline-item">
                                            <i class="layui-icon layui-timeline-axis"></i>
                                            <div class="layui-timeline-content layui-text">
                                                <h3 class="layui-timeline-title">@crmAuditLog.CreateDate</h3>
                                                <p>

                                                    @crmAuditLog.Reviewer @crmAuditLog.Cont<br />
                                                    @if (!string.IsNullOrEmpty(crmAuditLog.Remark))
                                                    {
                                                        @Html.Raw("备注:") @crmAuditLog.Remark

                                                    }
                                                </p>
                                            </div>
                                        </li>

                                    }
                                }
                            </ul>
                        </div>
                    </div>
                    @if (ViewBag.promotions != null)
                    {
                        AntUnion.FrameWork.Model.Models.Promotion promotion = ViewBag.promotions as AntUnion.FrameWork.Model.Models.Promotion;
                        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                            <legend lay-event='toExamine'>审核</legend>
                            <div class="layui-form">
                                <div class="layui-row layui-col-space10 layui-form-item">
                                    <div class="layui-col-lg10">
                                        <label class="layui-form-label" style="width:100px" lay-event='currentReviewer'>
                                            当前审核人：
                                        </label>
                                        <div class="layui-input-block">
                                            <div class="layui-form-mid layui-word-aux">@ViewBag.LoginName</div>
                                            <input id="reviewer" name="reviewer" type="hidden" value="@ViewBag.LoginName" />
                                        </div>
                                    </div>

                                    <div class="layui-col-lg10">
                                        <div class="layui-input-block">
                                            <input id="Id" name="Id" type="hidden" value="@promotion.Id" />
                                            <input type="radio" name="State" value="2" title="通过" @Html.Raw(promotion.State == 2 ? " checked=\"checked\"" : "") lay-event='pass'>
                                            <input type="radio" name="State" value="1" title="拒绝" @Html.Raw(promotion.State == 3 ? " checked=\"checked\"" : "") lay-event='refuse'>
                                        </div>
                                    </div>
                                    <div class="layui-col-lg10">
                                        <label class="layui-form-label" lay-event="programme">返佣方案</label>
                                        <div class="layui-input-inline">
                                            <select name="programme" id="programme">
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-col-lg10">
                                        <label class="layui-form-label" lay-event='remark'>备注</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="remarks" id="remarks" lay-verify="title" autocomplete="off" placeholder="refusalToFillInPrompt" class="layui-input" value="@promotion.Remarks">
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </fieldset>
                        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                            <legend></legend>
                        </fieldset>
                        <div class="layui-form">
                            <div class="layui-input-block">
                                @if (promotion.State == 0)
                                {
                                    <button class="layui-btn" id="confirmBtn" lay-event="confirmBtn" lay-submit lay-filter="identityInfoConfirmBtn">确认</button>

                                }
                                <button class="layui-btn layui-btn-primary" id="goBack" lay-event="goBack" lay-submit lay-filter="identityInfoCancel">返回</button>
                            </div>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>
